3 // Wrapper for a Fusion Activation Context (ACTCTX)
4 class ActivationContext
6 ActivationContext(const ActivationContext
&);
7 void operator =(const ActivationContext
&);
10 m_hActCtx(INVALID_HANDLE_VALUE
),
12 m_fAutoDeactivate(true)
18 if(m_hActCtx
!= INVALID_HANDLE_VALUE
)
20 // If we don't deactivate the context, we can't release it either.
24 ReleaseActCtx(m_hActCtx
);
29 bool Create(LPCWSTR manifestModulePath
)
31 if (m_hActCtx
!= INVALID_HANDLE_VALUE
|| !manifestModulePath
|| !*manifestModulePath
)
37 ACTCTXW actctx
= { sizeof(actctx
) };
38 actctx
.lpSource
= manifestModulePath
;
39 actctx
.lpResourceName
= MAKEINTRESOURCEW(2);
40 actctx
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
;
42 m_hActCtx
= CreateActCtxW(&actctx
);
43 return m_hActCtx
!= INVALID_HANDLE_VALUE
;
46 bool Activate(bool autoDeactivate
= true)
48 if(m_hActCtx
== INVALID_HANDLE_VALUE
)
53 m_fAutoDeactivate
= autoDeactivate
;
54 return ActivateActCtx(m_hActCtx
, &m_actCtxCookie
) != false;
59 if(m_hActCtx
== INVALID_HANDLE_VALUE
|| m_actCtxCookie
== 0)
64 ULONG_PTR cookie
= m_actCtxCookie
;
66 return DeactivateActCtx( 0, cookie
) != false;
71 ULONG_PTR m_actCtxCookie
;
72 bool m_fAutoDeactivate
;